#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include"listitembox.h"
#include"musiclist.h"
#include<QMediaPlaylist>

namespace Ui {
class CommonPage;
}


enum PageType
{
    LIKE_PAGE,
    LOCAL_PAGE,
    RECENT_PAGE
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

    void setCommonPageUi(const QString& title,const QString& imagePath);
    void setMuiscPageType(PageType pageType);
    void addMusicToMusicPage(MusicList& musiclist);
    void reFresh(MusicList& musiclist);
    MusicList musicList;
    void addMusicToPlayer(MusicList& musicList,QMediaPlaylist* playList);
    QString getMusicIdByIndex(int index);
    void setImageLabel(QPixmap pixmap);
signals:
    void updataLikeMusic(bool isLike,const QString& musicId);
    void playAll(PageType pageType);
    void playMusicByIndex(CommonPage* page,int index);

private:
    Ui::CommonPage *ui;
    PageType pageType;
    QVector<QString> musicListOfPage;
};

#endif // COMMONPAGE_H
